//显示对话框
// @Bind #btnEditUser.onClick
!function() {
	var dialog = this.get("#dialogText");
	dialog.show();
};

// 关闭窗口
// @Bind #cancelUser.onClick
!function() {
	var dialog = this.get("#dialogText");
	dialog.close();
};

// 单选框按钮
// @Bind #readiogroupUser.onClick
!function() {
	var readioValue = this.get("#readiogroupUser.value");
	var authenticateUser = this.get("#authenticationUsername");
	var btnEditUser = this.get("#btnEditUser");

	// 右边
	var username = this.get("#username");
	var command = this.get("#command");
	var Enablecommand = this.get("#enableCommand");
	if (readioValue == "使用用户名/口令") {
		authenticateUser.set("readOnly", true);
		btnEditUser.set("disabled", true);

		username.set("readOnly", false);
		command.set("readOnly", false);
		Enablecommand.set("readOnly", false);
	} else {
		authenticateUser.set("readOnly", false);
		btnEditUser.set("disabled", false);

		username.set("readOnly", true);
		command.set("readOnly", true);
		Enablecommand.set("readOnly", true);
	}
};

// 添加认证用户
// @Bind #addUser.onClick
!function() {
	var datagridAuthenticateUser = this.get("#datagridAuthenticateUser");
	var dataSetAuthenticateUser = this.get("#dataSetAuthenticateUser");
	datagridAuthenticateUser.set("readOnly", false);
	dataSetAuthenticateUser.insert();
};

// 保存认证用户
// @Bind #saveUser.onClick
!function() {
	var datagridAuthenticateUser = this.get("#datagridAuthenticateUser");
	var dataSetAuthenticateUser = this.get("#dataSetAuthenticateUser");
	datagridAuthenticateUser.set("readOnly", true);
	// 获取控件ajaxaction
	var action = view.get("#updateActionAuthenticateUser");
	action.execute(function(result) {
		dataSetAuthenticateUser.flush();
	});

};

// 编辑认证用户
// @Bind #editUser.onClick
!function() {
	var editUser = this.get("#editUser");
	var datagridAuthenticateUser = this.get("#datagridAuthenticateUser");
	if (editUser.get("caption") == "编辑") {
		editUser.set("caption", "取消编辑");
		datagridAuthenticateUser.set("readOnly", false);
	} else {
		editUser.set("caption", "编辑");
		datagridAuthenticateUser.set("readOnly", true);
	}
};

// 删除认证用户
// @Bind #deleteUser.onClick
!function() {
	var dataSetAuthenticateUser = this.get("#dataSetAuthenticateUser");
	dataSetAuthenticateUser.getData("#").remove();
};

// @Bind #btnOk.onClick
!function() {
	var action = view.get("#ajaxActionDeviceMessage");
	var autoForm = view.get("#autoFormdevicemessage");
	var entity = autoForm.get("entity");
	action.set("parameter", entity);
	action.execute(function(result) {
		dorado.MessageBox.alert(result);
	});
};

// @Bind #btnCancel.onClick
!function() {

};
